<?php //debug($this->data)?>
<?php echo $javascript->link('prototype', false); ?> 
<?php echo $javascript->link('scriptaculous.js?load=effects', false); ?> 
<?php echo $javascript->link('controls', false); ?>

<div class="form-articles form">
<?php echo $form->create('Article',array('type' => 'file'));?>
	<fieldset>
 		<legend><?php __('Edit Article');?></legend>
	<?php
		echo $form->input('id');
		//echo $form->input('user_id');
		//echo $form->hidden('user_id');
		?>
		<?php echo $form->input('title'); ?>
		
		<?php echo $form->input('intro', array('rows'=>4));?>
		<?php echo $form->input('body', array('rows'=>12));?>
		<div class="block">
			<div class="element"><?php echo $form->input('published', array('class'=>'inline')); ?></div>
			<div class="element"><?php echo $form->input('newsletter', array('disabled'=>'true', 'type'=>'checkbox')); ?></div>
			<div class="element"><label><?php __('Article views');?></label> <p><?php if(!empty($this->data['Article']['views'])) echo $this->data['Article']['views']?></p></div>
		</div>
		
	
	</fieldset>
	<?php if(isset($this->data['Article']['id'])):?>
	<fieldset>
		<legend><?php __('Add upload');?></legend>
		<div class="block">
			<div class="element"><?php echo $form->input('Upload.title', array('value'=>'')); ?></div>
			<div class="element"><?php echo $form->input('Upload.filename', array('type' => 'file','label' => 'Upload a new file')); ?></div>
			<?php echo $form->hidden('Upload.article_id', array('value'=>$this->data['Article']['id']));?>
		</div>	
	</fieldset>
	<?php endif;?>
	<div class="block">
		<div class="element">
			<?php echo $form->submit(__('Save', true));?>
		</div>
		<div class="element">
			<?php echo $form->submit(__('Save and close', true), array('name'=>'close'));?>
		</div>
	</div>
	<?php echo $form->end();?>
	
	<div class="secondary">
		<?php if(isset($this->data['Article']['id'])):?>
		<fieldset>
			<legend><?php __('Uploads');?></legend>
			<?php if(!empty($this->data['Upload'])):?>
			<div class="image-wrapper float-break" id="images">
				<?php  echo $this->renderElement("../articles/admin_viewuploads", array('uploads' => $this->data['Upload'])); ?>
			</div>	
			<?php endif; ?>
		</fieldset>	
		<?php endif;?>
	</div>
	<?php //debug($this->data)?>
</div>
